package com.chen.authority.common.response;

import cn.hutool.http.HttpStatus;
import com.chen.authority.common.constant.SysConstant;

import java.util.Collection;

/**
 * 多重响应
 *
 * @author chengy
 * @date 2022/09/27
 */
public class MultiResponse<T> extends Response {

    /**
     * 响应数据
     */
    private Collection<T> data;

    public Collection<T> getData() {
        return data;
    }

    public void setData(Collection<T> data) {
        this.data = data;
    }

    /**
     * 成功响应（带数据）
     *
     * @param data 数据
     * @param <T>  数据类型
     * @return 多重响应
     */
    public static <T> MultiResponse<T> success(Collection<T> data) {
        MultiResponse<T> multiResponse = new MultiResponse<>();
        multiResponse.setCode(HttpStatus.HTTP_OK);
        multiResponse.setMessage(SysConstant.SUCCESS_MSG);
        multiResponse.setData(data);
        return multiResponse;
    }

}
